﻿using CuoiHoi.Business;
using CuoiHoi.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CuoiHoi.UserControls
{
    public partial class ThongTin : System.Web.UI.UserControl
    {
        public ETinTuc TinTuc;
        protected void Page_Load(object sender, EventArgs e)
        {
            int idTheLoai = int.Parse(Page.RouteData.Values["IdInfo"].ToString());
            string Title = Page.RouteData.Values["TitleThongTin"].ToString();

            TinTuc = BTinTuc.SelectByIDTL(idTheLoai);

            if (TinTuc.NoiDung != null)
            {
                ETheLoai TheLoai = BTheLoai.SelectByID(idTheLoai);

                if (Router.NonUnicode(TheLoai.TenTheLoai) != Title)
                    Response.RedirectToRoute("ThongTin",
                        new
                        {
                            TitleThongTin = Router.NonUnicode(TinTuc.TieuDe),
                            IdInfo = TinTuc.idTinTuc,
                        });
            }
            //else
            //    Response.RedirectToRoute("Error");
        }
    }
}